<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            width: 600px;
            height: 600px;
            margin: auto;
            background-color: pink;
        }
    </style>
    <script src="./lib/jquery-3.4.1.min.js"></script>
</head>

<body>
    <script>
        Array.prototype.indexValue = function (arr) {
            // sname 匹配 规则，此处的 this 代表当前的 Array
            for (var i = 0; i < this.length; i++) {
                if (this[i].sname == arr) {                    
                    return i;
                }
            }
            return i==this.length?i:-1;
        }
        var sname = "GF6"
        // sid 值一定和 卫星名称 sname 对牢，接和下面 mmode 一致
        const sateinfo = [
            { "sid": 0, "sname": "GF1" },
            { "sid": 1, "sname": "GF2" },
            { "sid": 2, "sname": "GF1B" },
            { "sid": 3, "sname": "GF1C" },
            { "sid": 4, "sname": "GF1D" },
            { "sid": 5, "sname": "GF5" },
            { "sid": 6, "sname": "GF6" },
            { "sid": 7, "sname": "SV1" },
            { "sid": 8, "sname": "SV2" },
            { "sid": 9, "sname": "SV3" },
            { "sid": 10, "sname": "SV4" },
            { "sid": 11, "sname": "ZY30" },
            { "sid": 12, "sname": "PIBS" },
            { "sid": 13, "sname": "TRIP" },
            { "sid": 14, "sname": "GF7" },
            { "sid": 15, "sname": "ZY02C" },
            { "sid": 16, "sname": "ZY02C_PMS" },
            { "sid": 17, "sname": "P2AS" },
            { "sid": 18, "sname": "TRIPLESAT" }
        ]
        // 以GF1配置为例 json对象
        const mmode = {
            "xmltypes": [
                {
                    "name": "GF系列",
					"describe1":"(源文件，也可以解析tiff文件)GF1_PMS1_E118.6_N27.7_20200218_L1A0004623047-PAN1.xml => （filename字段，文件名）GF1_PMS1_E118.6_N27.7_20200218_L1A0004623047",
					"describe2":"（filename字段，文件名）GF1_PMS1_E118.6_N27.7_20200218_L1A0004623047 =>（解析原始影像文件，解析成）GF1 L1A0004623047 20200218  =>(changename字段生成规则：卫星号，订单号，时间；组成新文件名，并以F结尾) GF1L1A000462304720200218F",
					"attention":"resolution分辨率: (PAN1/PAN2：0.8 or MSS1/MSS2：3.2)（云量：有可能是浮点数，%为单位）,（RollViewingAngle如是 负数的则改成 正的数字）",
                    "GF1": {
						"filename":"describe1",
						"changename":"describe2",
                        "acquisition_time": "CenterTime",
                        "resolution": "(0.8 or 3.2)",
                        "cloud_percent": "CloudPercent",
                        "View_angle": "RollViewingAngle",
                        "topleft_latitude": "TopLeftLatitude",
                        "topleft_longitude": "TopLeftLongitude",
                        "topright_latitude": "TopRightLatitude",
                        "topright_longitude": "TopRightLongitude",
                        "bottomright_latitude": "BottomRightLatitude",
                        "bottomright_longitude": "BottomRightLongitude",
                        "bottomleft_latitude": "BottomLeftLatitude",
                        "bottomleft_longitude": "BottomLeftLongitude"
                    }
                },
                {
                    "name": "[请加描述]系列",
                    "matched_mode": {
						"filename":"",
						"changename":"",
                        "acquisition_time": "",
                        "resolution": "",
                        "cloud_percent": "",
                        "View_angle": "",
                        "topleft_latitude": "",
                        "topleft_longitude": "",
                        "topright_latitude": "",
                        "topright_longitude": "",
                        "bottomright_latitude": "",
                        "bottomright_longitude": "",
                        "bottomleft_latitude": "",
                        "bottomleft_longitude": ""
                    }
                }
            ]
        }
        $(document).ready(function () {// 入口函数
            $('div').hide();

            // 通过 sname 找到 对应的 sid ，即 index，在下面直接使用
            const index = find_sid(sname);
            console.log(mmode['xmltypes'][0]['GF1']);
            myJson = { "name": "phpernote", "password": "1111" };
            console.log(myJson);
            for (var val in myJson) {
                console.log(val + " " + myJson[val]);//输出如:name 
            }
        });

    </script>
    <input type="button" value="显示" onclick="showdiv()">
    <input type="button" value="隐藏" onclick="hidediv()">
    <div>
    </div>
    <script>
        function showdiv() {
            console.log('I want to show the div');
            $('div').show();
            console.dir($('div'));
        }
        function hidediv() {
            console.log('I want to hide the div');
            $('div').hide();
            console.dir(document.querySelector('div'));
        }
        function find_sid(sname) {
            let i = sateinfo.indexValue(sname);
            console.log("my sateinfo is : ", sname, sateinfo, i, sateinfo[i].sid);
            
        }
    </script>
</body>

</html>